import 'package:flutter/material.dart';

class ProgressWidget extends StatefulWidget {
  @override
  State<StatefulWidget> createState() {
    return new ProgressState();
  }
}

class ProgressState extends State<ProgressWidget>
    with SingleTickerProviderStateMixin {
  AnimationController _animationController;

  @override
  void initState() {
    super.initState();
    _animationController =
        new AnimationController(duration: Duration(seconds: 5));
    _animationController.forward();
    _animationController.addListener((){
      setState(() {
       print(_animationController.value);
      });
    });
  }

  @override
  Widget build(BuildContext context) {
    return new Scaffold(
      appBar: AppBar(
        title: Text("progress"),
      ),
      body: new Padding(
        padding: EdgeInsets.all(15),
        child: new Column(
          children: <Widget>[
            //进度条指示器
            LinearProgressIndicator(
              backgroundColor: Colors.grey,
              valueColor:
                  //颜色渐变
                  ColorTween(begin: Colors.greenAccent, end: Colors.redAccent)
                      .animate(_animationController),
              value: _animationController.value,
            ),
            //圆形进度条
            CircularProgressIndicator(
              backgroundColor: Colors.grey,
              valueColor: AlwaysStoppedAnimation(Colors.blue),
              strokeWidth: 5,
            ),
            //设置尺寸
            SizedBox(
              width: 100,
              height: 100,
              child: CircularProgressIndicator(
                backgroundColor: Colors.grey,
                valueColor:
                ColorTween(begin: Colors.greenAccent, end: Colors.redAccent)
                    .animate(_animationController),
                strokeWidth: 7,
              ),
            ),
          ],
        ),
      ),
    );
  }
}
